using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using TrainingManagement.api.Models.BusinessLogic.Employee;
using TrainingManagement.api.Models.BusinessObjects;

namespace TrainingManagement.web.Models.ViewModels
{
    public class EmployeeCreateViewModel
    {
        [ScaffoldColumn(false)]
        public int EmployeeId { get; set; }

        [Display(Name = "Username")]
        public string UserName { get; set; }

        [Display(Name = "Password"), MaxLength(18)]
        public string Password { get; set; }
        
        [Display(Name = "First Name")]
        public string FirstName { get; set; }

        [Display(Name = "Last Name")]
        public string LastName { get; set; }

        [Display(Name = "Email")]
        public string Email { get; set; }

        [Display(Name = "SMS Number")]
        public string SmsNumber { get; set; }

        [Display(Name = "Reports To")]
        private SelectList _reportsTo;
        public SelectList ReportsTo
        {
            get { return GetEmployee(null); }
            set { _reportsTo = value; }
        }

        public EmployeeCreateViewModel(){}

        private static SelectList GetEmployee(int? employeeId)
        {
            var employees = new EmployeeSelectOperation().Run(employeeId);
            var selectList = new SelectList(employees, "EmployeeId", "FullName");
            return selectList;
        } 
    }
}